package com.gitee.dprecated.service;

import com.gitee.dprecated.state.CreateOrder;
import com.gitee.dprecated.state.OrderPO;
import com.gitee.dprecated.state.PayOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 商品订单状态转化与处理 观察者模式
 *
 * @author acao
 * @since 2023-11-07 09:56
 */
@Service
public class OrderService {

    @Autowired
    private CreateOrder createOrder;

    @Autowired
    private PayOrder payOrder;

    /**
     * 创建订单
     *
     * @param productId 商品Id
     */
    public OrderPO createOrder(String productId) {
        //订单Id的生成逻辑，笔者有话要说... ...
        String orderId = "OID" + productId;
        return createOrder.createOrder(orderId, productId);
    }

    /**
     * 订单支付
     */
    public OrderPO pay(String orderId) {

        return payOrder.payOrder(orderId);
    }


}
